package com.pgytesting.secondhandcar.service.impl;

import com.pgytesting.secondhandcar.model.ManagementInformation;
import com.pgytesting.secondhandcar.dao.ManagementInformationDao;
import com.pgytesting.secondhandcar.service.ManagementInformationService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (ManagementInformation)表服务实现类
 *
 * @author makejava
 * @since 2019-08-15 14:35:54
 */
@Service("managementInformationService")
public class ManagementInformationServiceImpl implements ManagementInformationService {
    @Resource
    private ManagementInformationDao managementInformationDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public ManagementInformation queryById(Integer id) {
        return this.managementInformationDao.queryById(id);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit 查询条数
     * @return 对象列表
     */
    @Override
    public List<ManagementInformation> queryAllByLimit(int offset, int limit) {
        return this.managementInformationDao.queryAllByLimit(offset, limit);
    }
    
    /**
     * 条件查询多条数据
     *
     * @param managementInformation 实例对象
     * @return 对象列表
     */
    @Override
    public List<ManagementInformation> queryAll(ManagementInformation managementInformation) {
        return this.managementInformationDao.queryAll(managementInformation);
    }

    /**
     * 新增数据
     *
     * @param managementInformation 实例对象
     * @return 实例对象
     */
    @Override
    public ManagementInformation insert(ManagementInformation managementInformation) {
        this.managementInformationDao.insert(managementInformation);
        return managementInformation;
    }

    /**
     * 修改数据
     *
     * @param managementInformation 实例对象
     * @return 实例对象
     */
    @Override
    public ManagementInformation update(ManagementInformation managementInformation) {
        this.managementInformationDao.update(managementInformation);
        return this.queryById(managementInformation.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.managementInformationDao.deleteById(id) > 0;
    }
}